﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinCourseControls
{
    public partial class FrmContextMenuStrip : Form
    {
        public FrmContextMenuStrip()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 红色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miRed_Click(object sender, EventArgs e)
        {
            //  this.BackColor = Color.Red;
            // cmsMenus01.SourceControl - 让右键菜单作用于绑定的控件
            cmsMenus01.SourceControl.BackColor = Color.Red; 
        }

        /// <summary>
        /// 蓝色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miBlue_Click(object sender, EventArgs e)
        {
            // cmsMenus01.SourceControl - 让右键菜单作用于绑定的控件
            cmsMenus01.SourceControl.BackColor = Color.Blue;
        }

        /// <summary>
        /// 默认色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miSetDefault_Click(object sender, EventArgs e)
        {
            // cmsMenus01.SourceControl - 让右键菜单作用于绑定的控件
            cmsMenus01.SourceControl.BackColor = SystemColors.Control;
        }

        /// <summary>
        /// 绿色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miGreen_Click(object sender, EventArgs e)
        {
            // cmsMenus01.SourceControl - 让右键菜单作用于绑定的控件
            cmsMenus01.SourceControl.ForeColor = Color.Green;
        }

        /// <summary>
        /// 浅蓝色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miLightBlue_Click(object sender, EventArgs e)
        {
            // cmsMenus01.SourceControl - 让右键菜单作用于绑定的控件
            cmsMenus01.SourceControl.ForeColor = Color.LightBlue;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.ContextMenuStrip = cmsMenus01; // 给文本控件绑定右键菜单
        }
    }
}
